package com.my.config;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;

import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import com.my.framework.web.mvc.handler.BaseControllerHandlerAdapter;
import com.my.toolkit.JsonUtil;


//@EnableWebMvc
@Configuration
public class MvcAutoConfiguration {
	//spring自动配置,放在这里方便以后查看
	org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration x;
	public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
	
	@Bean
	JsonUtil jsonUtil() {
		return new JsonUtil();
	}
	


	@Bean
	public BaseControllerHandlerAdapter baseControllerHandlerAdapter(JsonUtil jsonUtil,HttpMessageConverters converts) {
		List<HttpMessageConverter<?>> list=converts.getConverters();
		BaseControllerHandlerAdapter adapter=new BaseControllerHandlerAdapter(jsonUtil);
		adapter.setMessageConverters(list);
		return adapter;
	}
}
